<!--
  ~ The MIT License (MIT)
  ~
  ~ Copyright (c) 2016 CloudBees Inc.
  ~
  ~ Permission is hereby granted, free of charge, to any person obtaining a copy
  ~ of this software and associated documentation files (the "Software"), to deal
  ~ in the Software without restriction, including without limitation the rights
  ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  ~ copies of the Software, and to permit persons to whom the Software is
  ~ furnished to do so, subject to the following conditions:
  ~
  ~ The above copyright notice and this permission notice shall be included in all
  ~ copies or substantial portions of the Software.
  ~
  ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  ~ SOFTWARE.
  -->
<p>
    Reads a file in the current working directory or a String as a plain text
    <a href="https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html" target="_blank">Java Properties</a>
    file.
    The returned object is a normal Map with String keys.
    The map can also be pre loaded with default values before reading/parsing the data.
</p>
<strong>Fields:</strong>
<ul>
    <li>
        <code>file</code>:
        Optional path to a file in the workspace to read the properties from.
        <em>These are added to the resulting map after the defaults and so will overwrite any key/value pairs already present.</em>
    </li>
    <li>
        <code>text</code>:
        An Optional String containing properties formatted data.
        <em>These are added to the resulting map after <code>file</code> and so will overwrite any key/value pairs already present.</em>
    </li>
    <li>
        <code>defaults</code>:
        An Optional Map containing default key/values.
        <em>These are added to the resulting map first.</em>
    </li>
    <li>
        <code>interpolate</code>:
        Flag to indicate if the properties should be interpolated or not. <br>

        Prefix interpolations allowed by default are: <code>urlDecoder</code>, <code>urlEncoder</code>,
        <code>date</code>, <code>base64Decoder</code>, <code>base64Encoder</code>.

        Default prefix interpolations can be overridden by setting the
        <a href="https://www.jenkins.io/redirect/setting-system-properties">system property</a>: <br>
        <code>org.jenkinsci.plugins.pipeline.utility.steps.conf.ReadPropertiesStepExecution.CUSTOM_PREFIX_INTERPOLATOR_LOOKUPS</code><br>
        <b>Note that overriding default prefix interpolations can be insecure depending on which ones you enable.</b>

        In case of error or cyclic dependencies, the original properties will be returned.
    </li>
    <li>
        <code>charset</code>:
        What charset to use when read properties file. Default is empty, then will use jvm ISO 8859-1.
    </li>
</ul>
<p>
    <strong>Example:</strong><br/>
    <code>
        <pre>
        def d = [test: 'Default', something: 'Default', other: 'Default']
        def props = readProperties defaults: d, file: 'dir/my.properties', text: 'other=Override'
        assert props['test'] == 'One'
        assert props['something'] == 'Default'
        assert props.something == 'Default'
        assert props.other == 'Override'
        </pre>
    </code>
    <strong>Example with interpolation:</strong>
    <code>
        <pre>
        def props = readProperties interpolate: true, file: 'test.properties'
        assert props.url = 'http://localhost'
        assert props.resource = 'README.txt'
        // if fullUrl is defined to ${url}/${resource} then it should evaluate to http://localhost/README.txt
        assert props.fullUrl = 'http://localhost/README.txt'
        </pre>
    </code>
    <strong>Example with charset:</strong>
    <code>
        <pre>
        def props = readProperties charset: 'UTF-8', file: 'test.properties'
        </pre>
    </code>
</p>
